package com.headwind.logistics.order.service.impl;

import com.headwind.logistics.order.entity.OrderAbnormal;
import com.headwind.logistics.order.mapper.OrderAbnormalMapper;
import com.headwind.logistics.order.mapper.PlanOrderMappder;
import com.headwind.logistics.order.service.inter.OrderAbnormalServiceInter;
import com.headwind.logistics.order.util.OrderUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author 盛夏
 * @Date 2020-07-21 下午 10:40
 * @Version 1.0
 * @DESCRIPTION 填写类作用描述
 */
@Service
public class OrderAbnormalServiceImpl implements OrderAbnormalServiceInter {
    @Resource
    private OrderAbnormalMapper abnormalMapper;

    @Resource
    private PlanOrderMappder planOrderMappder;

    @Override
    public int addOrderAbnormal(Long goodsIssueTypeId, String remark,String planOrderOdd) {

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式

        OrderAbnormal orderAbnormal = new OrderAbnormal();
        orderAbnormal.setOrderAbnormalOdd("NFY"+ OrderUtil.getUUID());
        orderAbnormal.setOrderAbnormalTime(df.format(new Date()));
        orderAbnormal.setGoodsIssusTypeId(goodsIssueTypeId);
        orderAbnormal.setOrderId(planOrderOdd);
        orderAbnormal.setRemark(remark);

        planOrderMappder.updatePlanOrderStart("2",planOrderOdd);
        return abnormalMapper.addOrderAbnormal(orderAbnormal);
    }
}
